<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>模版语法：过滤器</title>
</head>
<body>
<h2>过滤器</h2>
<p>age = {{ age }}</p>
<p>age|add:5 = {{ age|add:5 }}</p>
<p>age|add:-2 = {{ age|add:-2 }}</p>

<p>name = {{ name }}</p>
<p>name|first|upper = {{ name|first|upper }}</p>
<p>name|last|lower = {{ name|last|lower }}</p>
<p>name|title = {{ name|title }}</p>

{# 从第7位开始省略 #}
<p>name|truncatechars:7 = {{ name|truncatechars:7 }}</p>

<p>likes = {{ likes }}</p>
<p>likes|join:"+" = {{ likes|join:"+" }}</p>

<p>likes1 = {{ likes1 }}</p>
<p>likes1|default:"swim" = {{ likes1|default:"swim" }}</p>

<p>dt = {{ dt }}</p>
<p>dt = {{ dt|date:"y-m-d" }}</p>
<p>dt = {{ dt|date:"Y-m-d" }}</p>

<p>code = {{ code }}</p>
<p>code = {{ code|safe }}</p>

<p>nosafe_code = {{ nosafe_code }}</p>
<p>nosafe_code = {{ nosafe_code|safe }}</p>
</body>
</html>